package com.stk.sinous;

import java.util.ArrayList;
import java.util.Random;

import org.andengine.entity.primitive.Line;
import org.andengine.entity.scene.Scene;

import android.util.Log;

public class Player{
	private ArrayList<Tail> tail;
	private final int LINE_NUMBER = 30;
	
	public Player(SinousActivity sa){
		tail = new ArrayList<Tail>();
	}

	public void addTail(SinousActivity sa, Scene scene, int x, int y){
		final Tail line;
		if (tail.size() > 0){
			line = new Tail(x, y,tail.get(tail.size()-1).getX1(), tail.get(tail.size()-1).getY1(), 3, sa.getVertexBufferObjectManager());
		}else{
			line = new Tail(x, y,x, y, 3, sa.getVertexBufferObjectManager());
		}
		
		if (tail.size() > LINE_NUMBER){
			scene.detachChild(tail.get(0));
			tail.remove(0);
		}
		
		line.setColor(51/255f,181/255f,229/255f);
		
		tail.add(line);
		scene.attachChild(line);
	}

	public Tail getLastTail() {	
		if (tail.size() > 0){
			return tail.get(tail.size()-1);
		}else{
			return null;
		}
		
	}
}
